<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<%@ page import="com.scalar.chiptrack.commons.Address,com.scalar.chiptrack.sales.TermsAndConditions,com.scalar.chiptrack.sales.forms.ApproverOrderForm,com.scalar.chiptrack.utils.ConfigManager,java.util.ArrayList"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% String salesOrderId = request.getParameter("salesOrderId"); %>
<%
	ApproverOrderForm approveOrderForm = (ApproverOrderForm) request.getAttribute("approverOrderForm");

    String closeWindowAfterSessionTimeOut = ( String ) request.getAttribute( "closeWindowAfterSessionExp" );
   if ( closeWindowAfterSessionTimeOut == null )
    {
%>
    <chiptrack:checkLogon sourcePage="/changeOrder.do"/>
<% } %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<script language="javaScript">
function showErrorReportPage()
{
    newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
    newWindow.focus();
}
function sendMail(salesOrderId)
{
  newWindow =
	   window.open ('<%=chipTracContext%>/sendAckMail.do?salesOrderId=' + salesOrderId , 'sendMailPopup1','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=800,height=550,resizable=yes');
    newWindow.focus();
}
</script>
<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<style type="text/css">
a { text-decoration : none}
</style>
</HEAD>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<%
if ( closeWindowAfterSessionTimeOut == null )
{
%>
<%
 String heading = "";
 String isSample = "1";
 String salesOrderFieldHeading = "";
%>
<% if((request.getParameter("isSample") != null) && (request.getParameter("isSample").equals("0"))) {
    heading = "Sample Order"; isSample="0";
    salesOrderFieldHeading = "Sample Sales Order#";

%>

<% } else {
    heading = "Sales Order";isSample="1";
    salesOrderFieldHeading = "Sales Order#";
%>

<% } %>
<html:html>

<%-- from here your body starts --%>
<html:form name="approverOrderForm" action="/approveOrder" method="post" type="com.scalar.chiptrack.sales.forms.ApproverOrderForm">

<p STYLE="page-break-after: always">
<nested:nest property="salesOrder">
<table width="98%" cellspacing='0' cellpadding='0' border=0 align=center>
    <tr>
        <td width="34%" align="left" valign="top"><img src="<%=chipTracContext%>/jsp/includes/images/scalar_logo.jpg" height="84" width='200' border=0></td>
        <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
        <td widht="30%" align="center" class="NArialL">
            <table border=0 cellspacing='0' cellpadding='0'>
                <tr><td align="center" nowrap><h3><%=heading%> Acknowledgement</h3></td></tr>
                <tr><td align="center" class="NArialL"><nested:write name="salesOrder" property="clientName"/></td></tr>
                <tr><td align="center" class="NArialL"><nested:write name="salesOrder" property="clientAddressAsHTML" filter="false"/></td></tr>
            </table>
        </td>
        <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
        <td width="34%" valign="top"><font class="NArialW">
            <table border=0 align="right">
                    <tr>
                        <td><a href="javascript:window.print();" title='Click here to Print Sales Order Details'><img src="<%=chipTracContext%>/jsp/includes/images/printer_icon_small.gif" width='80' border="0" alt="Click here to Print Sales Order Details"></a></td>
                        <td>&nbsp;</td>
                    </tr>
            </table>
        </font></td>
   </tr>
   <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
   <tr>
        <td height="100%">
            <table border=1 width="100%" height="100%" bordercolor='#000000' cellspacing='0' cellpadding='0'>
                <tr height=20><td class="NArialL" bgcolor="#DEE1E2">Ordered By :</td></tr>
                <tr height=20><td class="NArialL" valign="top"  bgcolor="#FFFFEE">
                    <table width="100%" class="NArialL" height=80 cellspacing='0' cellpadding='0'>
                        <%--<nested:notEqual name="salesOrder" property="billingContactPerson" value="" >
                        <tr><td><nested:write name="salesOrder" property="customerName"/></td></tr>
                        </nested:notEqual>--%>
							<tr><td><nested:write name="salesOrder" property="billingAddressAsHTML" filter="false"/></td></tr>
                    </table></td>
                </tr>
            </table>
        </td>
        <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
        <td height="100%">
            <table border=1 width="100%" height="100%"bordercolor='#000000' cellspacing='0' cellpadding='0'>
                <tr height=20><td class="NArialL" bgcolor="#DEE1E2">Bill To :</td></tr>
                <tr height=20><td class="NArialL" valign="top"  bgcolor="#FFFFEE">
                    <table width="100%" class="NArialL" height=80 cellspacing='0' cellpadding='0'>
                         <%--<nested:notEqual name="salesOrder" property="billingContactPerson" value="" >
                             <tr><td><nested:write name="salesOrder" property="customerName"/></td></tr>
                             </nested:notEqual>--%>
							<tr><td><nested:write name="salesOrder" property="billingAddressAsHTML" filter="false"/></td></tr>
                    </table></td>
                </tr>
            </table>
        </td>
        <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
        <td height="100%">
            <table border=1 width="100%"  height="100%"bordercolor='#000000' cellspacing='0' cellpadding='0'>
                <tr height=20><td class="NArialL" bgcolor="#DEE1E2">Ship To :</td></tr>
                <tr height=20><td class="NArialL"  valign="top" bgcolor="#FFFFEE">
                    <table width="100%" class="NArialL" height=80 cellspacing='0' cellpadding='0'>
                        <%--<tr><td><nested:write name="salesOrder" property="customerName"/></td></tr>--%>
							<tr><td><nested:write name="salesOrder" property="shippingAddressAsHTML" filter="false"/></td></tr>
                            <nested:nest property="shippingAddressAsObject">
                            </nested:nest>
                    </table></td>
                </tr>
            </table>
        </td>
   </tr>
   <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
   <tr>
        <td class="NArialL" height="100%">
            <table width="100%"height="100%" class="NArialL" border=1 bordercolor='#000000' cellspacing='0' cellpadding='0'>

                <tr height=20><td bgcolor='#DEE1E2'> Customer PO#</td><td bgcolor='#DEE1E2'><%=salesOrderFieldHeading%></td>
				<td bgcolor='#DEE1E2'> Change #</td>

				</tr>
                <tr height=20><td bgcolor='#FFFFEE'><nested:write property="customerPO"/>&nbsp;</td><td bgcolor='#FFFFEE'><nested:write property="salesOrderNo" />&nbsp;</td>

				<td bgcolor='#FFFFEE'><nested:write  property="changeNumber" />&nbsp;</td>

				</tr>

            </table>
        </td>
        <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
        <td class="NArialL" height="100%">
            <table width="100%" height="100%" class="NArialL" border=1 bordercolor='#000000' cellspacing='0' cellpadding='0'>
                <tr height=20><td bgcolor='#DEE1E2'> Order Date</td><td bgcolor='#DEE1E2'>Ship Via</td></tr>
                <tr height=20><td bgcolor='#FFFFEE'><nested:write name="salesOrder" property="salesOrderDate"/>&nbsp;</td>
                <td bgcolor='#FFFFEE'>
                <nested:notEqual property="shippingAccount" value="-1">
                    <nested:write property="shippingAccount"/>
                </nested:notEqual>
                &nbsp;
                </td>
                </tr>
            </table>
        </td>
        <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
        <td class="NArialL" height="100%">
            <table width="100%" height="100%"class="NArialL" border=1 bordercolor='#000000' cellspacing='0' cellpadding='0'>
                <tr height=20><td  bgcolor='#DEE1E2'> Sales Person</td><td bgcolor='#DEE1E2'>Regional Rep</td><td bgcolor='#DEE1E2'> Del Terms</td><td bgcolor='#DEE1E2'>Pay Terms</td></tr>
                <tr height=20>
                    <td bgcolor='#FFFFEE'><nested:write property="salesPerson" />&nbsp;</td>
                    <td bgcolor='#FFFFEE'><nested:write property="regionalRep"/>&nbsp;</td>
                    <td bgcolor='#FFFFEE'><nested:write property="deliveryTerms"/>&nbsp;</td>
                    <td bgcolor='#FFFFEE'>
                       <nested:notEqual property="shippingTerms" value="-1">
                            <nested:write property="shippingTerms"/>
                       </nested:notEqual>&nbsp;
                    </td>
                </tr>
            </table>
        </td>
   </tr>
   <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
   <tr><td colspan=5 class='NArialL'><U>Comments:</U></td></tR>
   <tr><td colspan=5 class='NArialL' bgcolor='#FFFFEE'><nested:write property="comments"/>&nbsp;</td></tR>
   </nested:nest>
   <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
   <tr><td colspan='5'>
       <% int noOfColumns = 13; %>
      <table width="100%" border=1 bordercolor='#000000' cellspacing='0' cellpadding='0'>
        <tr height=20>
            <td bgcolor='#DEE1E2' class="NArialL" align=center>PO Line#</td>
            <td bgcolor='#DEE1E2' class="NArialL" align=center>Quantity</td>
            <logic:equal  parameter="action" value="printTransferQuote" scope="request">
                <td bgcolor='#DEE1E2' class="NArialL" align=center>Close</td>
                <td bgcolor='#DEE1E2' class="NArialL" align=center>Transferred</td>
                <% noOfColumns = noOfColumns + 2; %>
            </logic:equal>
            <td class="NArialL"  bgcolor='#DEE1E2' align=center>UM</td>
            <td  class="NArialL" bgcolor='#DEE1E2' align=center><bean:message key="label.mfgPartNumber" /></td>
            <% if(ConfigManager.getBooleanProperty(ConfigManager.PROP_SHOW_SALES_LINEITEM_MARKETING_PART_NUMBER)) { %>
                <td align="center" bgcolor="#DEE1E2" class="NArialL"><bean:message key="label.mktgPartNumber" /></td>
             <% noOfColumns ++; } %>
             <td  class="NArialL" bgcolor='#DEE1E2' align=center>
				<bean:message key="label.customerPartNumber"/>&nbsp;
			 </td>
            <td  class="NArialL" bgcolor='#DEE1E2' align=center>Description</td>
            <td  class="NArialL" bgcolor='#DEE1E2' align=center>Requested Dock Date</td>
            <td   class="NArialL" bgcolor='#DEE1E2' align=center>Scheduled<br> Ship Date</td>
            <td   class="NArialL" bgcolor='#DEE1E2' align=center>Revised<br> Ship Date</td>
          <%--  <td   class="NArialL" bgcolor='#DEE1E2' align=center>Lead Time</td>--%>
           <td bgcolor='#DEE1E2'  class="NArialL" align=center>Taxable<br> Yes or No</td>
           <td bgcolor='#DEE1E2'  class="NArialL" align=center>Expedite Fee<br> Yes or No</td>
           <td class="NArialL"  bgcolor='#DEE1E2' align=center> Unit <br>Price</td>
           <td class="NArialL"  bgcolor='#DEE1E2' align=center>Extended<br> Price</td>
        </tr>
        <% int j = 0; %>
<logic:iterate id="myHashMap" name="lineItemsWithSubtotals">
    <logic:iterate id="lineItemList" name="myHashMap" >
          <logic:iterate id="LineItem" name="lineItemList" property="key" type="com.scalar.chiptrack.sales.LineItem">
        <tr height=20>
            <td bgcolor='#FFFFEE'  class="NArialL" align=center><bean:write name="LineItem" property="poLineItemNo"/>&nbsp;</td>
            <td bgcolor='#FFFFEE'  class="NArialL" align=center><bean:write name="LineItem" property="quantity"/>&nbsp;</td>
            <logic:equal  parameter="action" value="printTransferQuote" scope="request">
                <td width="8%" bgcolor="#FFFFEE" class="NArialL" align=center>
                <logic:equal name="LineItem" property="isClose" value="true" >
                    CLOSED
                </logic:equal>
                <logic:notEqual name="LineItem" property="isClose" value="true" >
                    OPEN
                </logic:notEqual>
                </td>
                <td width="8%" bgcolor='#FFFFEE' class="NArialL" align=center>
                <logic:equal name="LineItem" property="isTransfer" value="true" >
                     TRANSFERRED
                </logic:equal>
                <logic:notEqual name="LineItem" property="isTransfer" value="true" >
                     NOT TRANSFERRED
                </logic:notEqual>
                </td>
            </logic:equal>
            <td  class="NArialL" bgcolor='#FFFFEE' align=center>ea</td>
            <td bgcolor='#FFFFEE'  class="NArialL" align=center nowrap><bean:write name="LineItem" property="manufacturingPartNo"/>&nbsp;</td>
            <% if(ConfigManager.getBooleanProperty(ConfigManager.PROP_SHOW_SALES_LINEITEM_MARKETING_PART_NUMBER)) { %>
                <td bgcolor='#FFFFEE'  class="NArialL" align=center nowrap><bean:write name="LineItem" property="marketingPartNo"/>&nbsp;</td>
             <% } %>
            <td bgcolor='#FFFFEE'  class="NArialL" align=center nowrap>
                <logic:equal value="-2" name="LineItem" property="customerPartNo">
                    <bean:write name="LineItem" property="newCustomerPartNo"/>&nbsp;
                </logic:equal>
                <logic:notEqual value="-2" name="LineItem" property="customerPartNo">
                    <bean:write name="LineItem" property="customerPartNo"/>&nbsp;
                </logic:notEqual>

            </td>
            <td bgcolor='#FFFFEE'  class="NArialL" wrap><bean:write name="LineItem" property="lineItemDescription"/>&nbsp;</td>
            <td  class="NArialL" bgcolor='#FFFFEE' align=center><bean:write name="LineItem" property="requestDate"/>&nbsp;</td>
            <td  bgcolor='#FFFFEE'  class="NArialL" align=center><bean:write name="LineItem" property="scheduleDate"/>&nbsp;</td>
            <td  bgcolor='#FFFFEE'  class="NArialL" align=center><bean:write name="LineItem" property="revisedDate"/>&nbsp;</td>
            <%--<td  bgcolor='#FFFFEE'  class="NArialL" align=center><bean:write name="LineItem" property="leadTime"/>&nbsp;</td>--%>
            <td  class="NArialL" bgcolor='#FFFFEE' align=center><bean:write name="LineItem" property="isTaxableAsString"/>&nbsp;</td>
            <td  class="NArialL" bgcolor='#FFFFEE' align=center>
               <logic:equal name="LineItem" property="isExpedite" value="true">
               Yes
               </logic:equal>
               <logic:equal name="LineItem" property="isExpedite" value="false">
               No
               </logic:equal>
            </td>

            <td  class="NArialL" bgcolor='#FFFFEE' align=center><bean:write name="LineItem" property="unitPriceAsString"/>&nbsp;</td>
            <td  class="NArialL" bgcolor='#FFFFEE' align="right"><bean:write name="LineItem" property="amountAsString"/>&nbsp;</td>
        </tr>
        <%j++;%>
        </logic:iterate>
        <tr height="20 ">
            <td colspan="1"  bgcolor="#FFFFFF" class="NArialL" align="right">
                Sub Total&nbsp;
            </td>
            <bean:define id="subTotal" name="lineItemList" property="value" type="com.scalar.chiptrack.sales.SubTotal"/>
            <td colspan="1" bgcolor="#FFFFFF" class="NArialL" align="center">
                <bean:write name="subTotal" property="subTotalQty" />
            </td>
            <logic:equal  parameter="action" value="printTransferQuote" scope="request">
            <td colspan="<%=noOfColumns-3%>">&nbsp;</td>
            </logic:equal>
            <logic:notEqual parameter="action" value="printTransferQuote" scope="request">
            <td colspan="<%=noOfColumns-3%>">&nbsp;</td>
            </logic:notEqual>
            <td colspan="1" bgcolor="#FFFFFF" class="NArialL" align="right">
                <bean:write name="subTotal" property="subTotalAmt" />&nbsp;
            </td>
        </tr>
     </logic:iterate>
</logic:iterate>
     </table>
     <% if (j == 0){%>
     <font class="NArialL"><li>All the line items have been cancelled.</font>
     <%}%>
     </td></tr>
    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
     <tr><td colspan='5'>
        <nested:nest property="salesOrder">
        <table width='35%' border=1 align=left bordercolor='#000000' cellspacing='0' cellpadding='0'>
            <tr>
                <td class='NArialL' bgcolor='#DEE1E2'><bean:message key="label.sales.endCustomer"/> </td>
                <td class='NArialL' bgcolor='#DEE1E2'><bean:message key="label.sales.endUser"/></td>
                <td class='NArialL' bgcolor='#DEE1E2'>Quotation No</td>
            </tr>
            <tr>
                <td class='NArialL' bgcolor='#FFFFEE'>&nbsp;<nested:write property="odm"/></td>
                <td class='NArialL' bgcolor='#FFFFEE'>&nbsp;<nested:write property="endCustomer"/></td>
                <td class='NArialL' bgcolor='#FFFFEE'>
                    &nbsp;
                    <nested:notEqual value="null" property="quotationNo">
                        <nested:write property="quotationNo" />
                    </nested:notEqual>
                </td>
            </tr>
        </table>
        <table width="20%" border=1 align=right bordercolor='#000000'  cellspacing='0' cellpadding='0'>
        <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
        <tr>
            <td bgcolor='#DEE1E2' class="NArialL">Total</td><td bgcolor='#DEE1E2' class="NArialL"  align="right"><nested:write property="finalSubTotalAsString"/>&nbsp;</td>
        </tr>
        <tr><td bgcolor='#DEE1E2' class="NArialL">Sales Tax</td><td bgcolor='#DEE1E2'  class="NArialL" align="right"><nested:write property="finalSalesTaxAsString"/>&nbsp;</td>
        </tr>
        <tr><td bgcolor='#DEE1E2' class="NArialL">Freight</td><td bgcolor='#DEE1E2'  class="NArialL" align="right"><nested:write property="frieghtAsString"/>&nbsp;</td>
        </tr>                                       
        <tr><td bgcolor='#DEE1E2' class="NArialL"><nested:write name="salesOrderForm" property="miscName"/></td><td class="NArialL" bgcolor='#DEE1E2' align="right"><nested:write property="miscAsString"/>&nbsp;</td>
        </tr>
        <tr><td bgcolor='#DEE1E2' class="NArialL">Balance Due</td><td  class="NArialL" bgcolor='#DEE1E2' align="right"><nested:write property="finalOrderTotalAsString"/>&nbsp;</td>
        </tr>
        </nested:nest>
       </table></td></tr>
    </table>
   </td></tr>
    <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
    <%   if(ConfigManager.getShowTermsLabel())
    {%>
    <TR>
        <TD width='100%' colspan='3' class='NArialRS'><p><%=Constants.TERMS_LABEL %> </p></TD>
    </TR>
    <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tR>
    <%} %>
</table>
</p>
<p STYLE="page-break-after: always"></p>
<% if( ConfigManager.getShowTermsFromDB() )
{
%>
<table width="100%" cellspacing='5' cellpadding='0' border=0 align=center>
    <TR>
          <TD width='100%' valign="top" colspan="3" class="viewdata2"><center><b>Terms And Conditions</b></center></TD>
   </TR>
    <TR>
         <TD width='100%' valign="top" colspan="3" class="viewdata2"><center>
            <nested:nest property="salesOrder"><nested:write name="salesOrder" property="clientName"/> </nested:nest><br>
           <%
                Address address = approveOrderForm.getSalesOrder().getClientAddressAsObject();
                String clientAddress2 = approveOrderForm.getSalesOrder().getClientAddressToLoad(address);
				out.println(clientAddress2);
            %>
	</center></TD>
    </TR>
    <TR>
       <TD width='100%' colspan="3" class="viewdata1">&nbsp;</TD>
    </TR>

    <tr>

    <%
        ArrayList list = (ArrayList)request.getAttribute("termsAndConditions");
        if(list != null)
        {
            for(int i=0;i<list.size();i++)
            {
                TermsAndConditions terms = (TermsAndConditions)list.get(i);
    %>
                <tr><td bgcolor='#DEE1E2' class="viewdata1"><U><%=i+1%>.&nbsp;<%=terms.getTermsTitle().trim()%></U>&nbsp;<%=terms.getTerms().trim()%></td></tr>
                <%
            }
        }
    %>

</tr>
</table>
<%
    }
    else
    {
%>
  <p STYLE="page-break-after: always"></p>
<table width="98%" bordercolor='#000000' border='0' cellspacing='0' cellpadding='0' align="center">
    <TR>
          <TD width='100%' valign='top'><img src="<%=chipTracContext%>/jsp/includes/images/Terms and Condition of Sale.jpg" width='1000'/></TD>
   </TR>
</table>
<%}%>
<html:hidden name="approverOrderForm" property="salesOrderId"/>
</html:form>
 </html:html>
 <% } else { %>
    <table cellpadding='0' cellspacing='0' bgcolor='FDF5E6' border="0" width="100%"  height="100%" align=center>
        <tr>
            <td>
                <table align="center" border="0" width="40%" bgcolor="#FDF5E6">
                    <tr><td>&nbsp;</td></tr>
                    <tr><td align="center" ><font class="NArialL" ><font color="red">Session has been time out , Please close this window and login again.</font></font></td></tr>
                    <tr><td>&nbsp;</td></tr>
                    <tr><td align="center" ><a href="javascript:window.close();"><font class='NArialL'>[Close this window]</font></a></td></tr>
                </table>
            </td>
       </tr>
       <tr><td>&nbsp;</td></tr>
    </table>
<% } %>
<%-- till here --%>
</BODY>
</HTML>
